﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RootfusAddinHostAdapters
{
    class UtilityConverters
    {
        internal static RootfusHostView.ROOTObjectSpec ConvertROOTObjectSpec(RootfusAddinContracts.ROOTObjectSpec rtn)
        {
            if (rtn == null)
            {
                return null;
            }
            RootfusHostView.ROOTObjectSpec me = new RootfusHostView.ROOTObjectSpec();
            me._native_pointer = rtn._native_pointer;
            me._class_name = rtn._class_name;
            return me;
        }

        internal static RootfusAddinContracts.ROOTObjectSpec ConvertROOTObjectSpec(RootfusHostView.ROOTObjectSpec rtn)
        {
            if (rtn == null)
            {
                return null;
            }
            RootfusAddinContracts.ROOTObjectSpec me = new RootfusAddinContracts.ROOTObjectSpec();
            me._class_name = rtn._class_name;
            me._native_pointer = rtn._native_pointer;
            return me;
        }

        internal static RootfusHostView.ROOTObjectSpec[] ConvertROOTObjectSpecArray(RootfusAddinContracts.ROOTObjectSpec[] rtn)
        {
            if (rtn == null)
            {
                return null;
            }

            RootfusHostView.ROOTObjectSpec[] result = new RootfusHostView.ROOTObjectSpec[rtn.Length];
            int index = 0;
            foreach (var item in rtn)
            {
                result[index] = ConvertROOTObjectSpec(item);
                index += 1;
            }

            return result;
        }

        internal static RootfusAddinContracts.ROOTObjectSpec[] ConvertROOTObjectSpecArray(RootfusHostView.ROOTObjectSpec[] rtn)
        {
            if (rtn == null)
            {
                return null;
            }
            int index = 0;
            RootfusAddinContracts.ROOTObjectSpec[] result = new RootfusAddinContracts.ROOTObjectSpec[rtn.Length];
            foreach (var item in rtn)
            {
                result[index] = ConvertROOTObjectSpec(item);
                index += 1;
            }
            return result;
        }

    }
}
